]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
screenshot: Don't abuse StButton
authorZander Brown <zbrown@gnome.org>
Wed, 8 Nov 2023 10:50:02 +0000 (10:50 +0000)
committerMarge Bot <marge-bot@gnome.org>
Fri, 10 Nov 2023 20:19:13 +0000 (20:19 +0000)
It's an StBin, so can only have one child, yet we are adding multiple —
something we get away with by overriding allocate

Instead of doing that, move the content to it's own actor

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3010>

js/ui/screenshot.js

index c5c089c6bf08aeaa110bb9c3b7666f69ac03fe02..563fbed79d85347cd70e2a88e6e210c21168821c 100644 (file)
@@ -771,8 +771,8 @@ class UIWindowSelectorLayout extends Workspace.WorkspaceLayout {
     }
 });
 
-const UIWindowSelectorWindow = GObject.registerClass(
-class UIWindowSelectorWindow extends St.Button {
+const UIWindowSelectorWindowContent = GObject.registerClass(
+class UIWindowSelectorWindowContent extends Clutter.Actor {
     _init(actor, params) {
         super._init(params);
 
@@ -785,20 +785,21 @@ class UIWindowSelectorWindow extends St.Button {
         });
         this.add_child(this._actor);
 
-        this._border = new St.Bin({style_class: 'screenshot-ui-window-selector-window-border'});
+        this._border = new St.Bin({
+            style_class: 'screenshot-ui-window-selector-window-border',
+            child: new St.Icon({
+                icon_name: 'object-select-symbolic',
+                style_class: 'screenshot-ui-window-selector-check',
+                x_align: Clutter.ActorAlign.CENTER,
+                y_align: Clutter.ActorAlign.CENTER,
+            }),
+        });
         this._border.connect('style-changed', () => {
             this._borderSize =
                 this._border.get_theme_node().get_border_width(St.Side.TOP);
         });
         this.add_child(this._border);
 
-        this._border.child = new St.Icon({
-            icon_name: 'object-select-symbolic',
-            style_class: 'screenshot-ui-window-selector-check',
-            x_align: Clutter.ActorAlign.CENTER,
-            y_align: Clutter.ActorAlign.CENTER,
-        });
-
         this._cursor = null;
         this._cursorPoint = {x: 0, y: 0};
         this._shouldShowCursor = window.has_pointer && window.has_pointer();
@@ -810,26 +811,6 @@ class UIWindowSelectorWindow extends St.Button {
         return this._boundingBox;
     }
 
-    get windowCenter() {
-        const boundingBox = this.boundingBox;
-        return {
-            x: boundingBox.x + boundingBox.width / 2,
-            y: boundingBox.y + boundingBox.height / 2,
-        };
-    }
-
-    chromeHeights() {
-        return [0, 0];
-    }
-
-    chromeWidths() {
-        return [0, 0];
-    }
-
-    overlapHeights() {
-        return [0, 0];
-    }
-
     get cursorPoint() {
         return {
             x: this._cursorPoint.x + this._boundingBox.x - this._bufferRect.x,
@@ -943,6 +924,64 @@ class UIWindowSelectorWindow extends St.Button {
     }
 });
 
+const UIWindowSelectorWindow = GObject.registerClass(
+class UIWindowSelectorWindow extends St.Button {
+    _init(actor, params) {
+        super._init({
+            child: new UIWindowSelectorWindowContent(actor),
+            ...params,
+        });
+    }
+
+    get boundingBox() {
+        return this.child.boundingBox;
+    }
+
+    get windowCenter() {
+        const boundingBox = this.boundingBox;
+        return {
+            x: boundingBox.x + boundingBox.width / 2,
+            y: boundingBox.y + boundingBox.height / 2,
+        };
+    }
+
+    chromeHeights() {
+        return [0, 0];
+    }
+
+    chromeWidths() {
+        return [0, 0];
+    }
+
+    overlapHeights() {
+        return [0, 0];
+    }
+
+    get cursorPoint() {
+        return this.child.cursorPoint;
+    }
+
+    get bufferScale() {
+        return this.child.bufferScale;
+    }
+
+    get windowContent() {
+        return this.child.windowContent;
+    }
+
+    addCursorTexture(content, point, scale) {
+        this.child.addCursorTexture(content, point, scale);
+    }
+
+    getCursorTexture() {
+        return this.child.getCursorTexture();
+    }
+
+    setCursorVisible(visible) {
+        this.child.setCursorVisible(visible);
+    }
+});
+
 const UIWindowSelector = GObject.registerClass(
 class UIWindowSelector extends St.Widget {
     _init(monitorIndex, params) {